//
//  ZCDateViewController.swift
//  AlertViewController
//
//  Created by SmartStrategy on 2019/4/16.
//  Copyright © 2019 SmartStrategy. All rights reserved.
//

import UIKit

typealias AlertBlock = (()->Void)

class ZCDateViewController: UIViewController,UIViewControllerTransitioningDelegate {
    
    public var controllerBlock:AlertBlock?
    public var bgView:UIView?
    public var contentView:UIView?

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.view.backgroundColor = UIColor.clear
        self.bgView = UIView.init(frame: self.view.frame)
        self.bgView?.backgroundColor = UIColor.init(white: 0.5, alpha: 0.5)
        self.view.addSubview(self.bgView!)

        self.contentView = UIView.init()
        self.contentView?.backgroundColor = UIColor.white
        self.view.addSubview(self.contentView!)
        
        let tap = UITapGestureRecognizer.init(target: self, action: #selector(deleteView))
        self.bgView?.addGestureRecognizer(tap)
    }
    
    @objc func deleteView() {
        if self.controllerBlock != nil {
            self.controllerBlock!()
        }
    }
    
    public static func  showAlertView()->ZCDateViewController{
        let dataVC = ZCDateViewController()
        dataVC.transitioningDelegate = dataVC
        dataVC.modalPresentationStyle = UIModalPresentationStyle.custom
        return dataVC
        
    }
    
    lazy var presentObject:SFCenterAnimationPresentObject = {
        return SFCenterAnimationPresentObject()
    }()
    
    func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return self.presentObject
    }
    
    func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return self.presentObject
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
